Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add item to GROUP BY for new MySQL 5.7 default compatibility. #236

Merged

Conversation

t4k
Copy link
Contributor

@t4k t4k commented Jun 13, 2017

PHP message: PHP Fatal error: Uncaught Exception: There was a problem with the database: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'coral_organizations.OHP.parentOrganizationID’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in /var/www/coral/organizations/admin/classes/common/DBService.php:39
Stack trace:
#0 /var/www/coral/organizations/admin/classes/common/DBService.php(71): DBService->checkForError()
#1 /var/www/coral/organizations/admin/classes/domain/Organization.php(550): DBService->processQuery('SELECT O.organi…', 'assoc’)
#2 /var/www/coral/organizations/ajax_htmldata.php(895): Organization->search(Array, ‘TRIM(LEADING ‘T…’, ‘’)
#3 {main}
thrown in /var/www/coral/organizations/admin/classes/common/DBService.php on line 39

Issue #235

t4k added 2 commits June 13, 2017 14:40
PHP message: PHP Fatal error:  Uncaught Exception: There was a problem with the database: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'coral_organizations.OHP.parentOrganizationID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in /var/www/coral/organizations/admin/classes/common/DBService.php:39
Stack trace:
#0 /var/www/coral/organizations/admin/classes/common/DBService.php(71): DBService->checkForError()
#1 /var/www/coral/organizations/admin/classes/domain/Organization.php(550): DBService->processQuery('SELECT O.organi...', 'assoc')
#2 /var/www/coral/organizations/ajax_htmldata.php(895): Organization->search(Array, 'TRIM(LEADING 'T...', '')
#3 {main}
  thrown in /var/www/coral/organizations/admin/classes/common/DBService.php on line 39
The “Starts with” letter list was not working…
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'coral_organizations.O.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
@@ -639,7 +639,7 @@ public function getAlphabeticalList(){
$alphArray = array();
$result = mysqli_query($this->db->getDatabase(), "SELECT DISTINCT UPPER(SUBSTR(TRIM(LEADING 'The ' FROM name),1,1)) letter, COUNT(SUBSTR(TRIM(LEADING 'The ' FROM name),1,1)) letter_count
FROM Organization O
GROUP BY SUBSTR(TRIM(LEADING 'The ' FROM name),1,1)
GROUP BY SUBSTR(TRIM(LEADING 'The ' FROM name),1,1), O.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't produce what we want. This is trying to find which letters of the alphabet are represented by existing Organizations, and how many Organizations start with that letter. This change causes "letter_count" to be 1 for each letter. I don't have an easy test environment with MySQL 5.7, but I suggest trying "GROUP BY UPPER(SUBSTR(TRIM(LEADING 'The ' FROM name),1,1))" (that is, adding the "UPPER").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. It was working in my UI and I was hung up on the solution to the other issue in this pull request, but your approach is working and correct.

I’m going to remove this commit from this PR because it doesn’t have anything to do with the fatal error. I’ll add the fix to a different PR for Organizations where I am fixing some other issues.

@PaulPoulain PaulPoulain added the bug This is a bug (not an enhancement) label Dec 12, 2017
@jeffnm
Copy link
Member

jeffnm commented Apr 4, 2018

I can confirm this error occurs in mysql 5.7 and that this pr resolves that specific issue. I also don't see any immediate problems on 10.0.34-MariaDB.

Merging.

@jeffnm jeffnm added this to the Version 3.0.0 Beta milestone Apr 4, 2018
@jeffnm jeffnm merged commit 971c9fc into coral-erm:development Apr 4, 2018
@t4k t4k deleted the issue235-organizations-mysql-57 branch April 5, 2018 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug (not an enhancement)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants